#include<stdio.h>
// Why is the Data Structure version wrong???
int cnt;
static inline void move(char f, int n, char t) {
  printf("%c->%c\n", f, t);
  cnt++;
}
void hanoi(int n, char x, char y, char z) {
  if(n>0) {
    hanoi(n-1, x, z, y);
    move(x,n,z);
    hanoi(n-1, y,x,z);
  }
}
int solve() {
  int n;
  scanf("%d",&n);
  hanoi(n,'A','B','C');
  printf("%d\n", cnt);
  return 0;
}
int main() {
  int tc; tc = 1;
  for(int t = 1; t <= tc; t++) {
    solve();
  }
  return 0;
}
